/**
 * fileName:  NutritionBean.java
 * author:  Lei
 * Company:  Cloudland Studio
 * Createdate:  2014-6-4 下午10:19:15
 *
 * All rights Reserved, Designed By cloudland Copyright(C) 2010-2011
 *   
 * Modification  History:
 *     Date           Author        Version        
 * -------------------------------------------
 * 2014-6-4          Lei            1.0        
 *
 * Why & What is modified:
 * 1.0: 文件创建
 */
package org.cloudland.commercial.masterdata.handler.support;

import org.cloudland.commercial.masterdata.bean.MineralInfo;
import org.cloudland.commercial.masterdata.bean.NutrientInfo;
import org.cloudland.commercial.masterdata.bean.NutritionType;
import org.cloudland.commercial.masterdata.bean.VitamiInfo;
import org.cloudland.commercial.masterdata.store.entity.NutritionEntity;
import org.cloudland.commercial.masterdata.store.write.NutrientWriter;

 /**
 * <pre> 
 * TODO 请充分描述该类提供的作用, 或与其他类会有关联的使用。
 * 使用 java.lang.Object#toString(), 或者 {@link java.lang.Character Character} 等标签
 * </pre>
 * @ClassName  NutritionBean
 * @author  Lei
 * @version  %I%, %G%
 * @see  
 * @since   JDK1.6
 *
 */
public class NutritionBean implements MineralInfo, NutrientInfo, VitamiInfo {
	
	/**
	 * nutrientEntity 营养信息实体
	 */
	private NutritionEntity nutrientEntity;
	
	/**
	 * nutrientWriter 营养信息写入数据库操作
	 */
	private NutrientWriter nutrientWriter;

	/**
	 * <pre>
	 * TODO 请充分描述该构造函数的作用，及其参数的作用。
	 * </pre>
	 *   
	 */
	public NutritionBean(NutritionType type, NutrientWriter nutrientWriter) {
		this(new NutritionEntity(), nutrientWriter);
		this.nutrientEntity.setType(type);
	}
	
	/**
	 * <pre>
	 * TODO 请充分描述该构造函数的作用，及其参数的作用。
	 * </pre>
	 *
	 * @param nutrientEntity
	 * @param nutrientWriter   
	 */
	public NutritionBean(NutritionEntity nutrientEntity, NutrientWriter nutrientWriter) {
		this.nutrientEntity = nutrientEntity;
		this.nutrientWriter = nutrientWriter;
	}
	
	/**
	 * @return
	 */
	public String getId() {
		return nutrientEntity.getId();
	}
	
	/**
	 * @return
	 */
	public String getName() {
		return nutrientEntity.getName();
	}
	
	/**
	 * @return
	 */
	public String getDesc() {
		return nutrientEntity.getDesc();
	}
	
	/**
	 * @return
	 */
	public Integer getSort() {
		return nutrientEntity.getSort();
	}
	
	/**
	 * @return
	 */
	public NutritionType getType() {
		return nutrientEntity.getType();
	}
	
	/**
	 * @param nutritionName
	 */
	public void setName(String nutritionName) {
		nutrientEntity.setName(nutritionName);
	}
	
	/**
	 * @param nutritionDesc
	 */
	public void setDesc(String nutritionDesc) {
		nutrientEntity.setDesc(nutritionDesc);
	}
	
	/**
	 * @param sort
	 */
	public void setSort(Integer sort) {
		nutrientEntity.setSort(sort);
	}
	
	/**
	 * 提交
	 */
	public void submit() {
		
		if (null != nutrientEntity.getId() && nutrientEntity.getId().length() > 0) {
			this.nutrientWriter.update(nutrientEntity);
		} else {
			this.nutrientWriter.save(nutrientEntity);
		}
		
	}

}
